From: Keir Fraser Date: Fri, 23 Oct 2009 08:59:45 +0000 (+0100) Subject: minios: Optimize mmap(open("/dev/mem")) X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~13186 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22?a=commitdiff_plain;h=bee72b5893bfbffed54a1b3db46a99f4cb95f040;p=xen.git minios: Optimize mmap(open("/dev/mem")) Set map_frames_ex's stride parameter to 0 and increment to 1 to avoid building an explicit list of mfns. Signed-Off-By: Samuel Thibault --- diff --git a/extras/mini-os/lib/sys.c b/extras/mini-os/lib/sys.c index 1284f5a714..6e12be0f4a 100644 --- a/extras/mini-os/lib/sys.c +++ b/extras/mini-os/lib/sys.c @@ -1256,11 +1256,8 @@ void *mmap(void *start, size_t length, int prot, int flags, int fd, off_t offset unsigned long zero = 0; return map_frames_ex(&zero, n, 0, 0, 1, DOMID_SELF, 0, 0); } else if (files[fd].type == FTYPE_MEM) { - int i; - unsigned long mfns[n]; - for (i = 0; i < n; i++) - mfns[i] = ((unsigned long) offset + (i * PAGE_SIZE)) >> PAGE_SHIFT; - return map_frames_ex(mfns, n, 1, 0, 1, DOMID_IO, 0, _PAGE_PRESENT|_PAGE_RW); + unsigned long first_mfn = offset >> PAGE_SHIFT; + return map_frames_ex(&first_mfn, n, 0, 1, 1, DOMID_IO, 0, _PAGE_PRESENT|_PAGE_RW); } else ASSERT(0); }